import urllib.request
import gevent
from gevent import monkey

monkey.patch_all()


def download(img_name, img_url):
    req = urllib.request.urlopen(img_url)
    img = req.read()
    with open(img_name, 'wb') as f:
        f.write(img)


def main():
    gevent.joinall([
        gevent.spawn(download, '1.jpg', 'https://rpic.douyucdn.cn/live-cover/appCovers/2021/02/18/7547028_20210218133401_small.jpg'),
        gevent.spawn(download, '2.jpg','https://rpic.douyucdn.cn/live-cover/appCovers/2021/02/11/5445728_20210211185155_small.jpg')
    ])


if __name__ == '__main__':
    main()

